Repository navigation
gh-106045: Fix venv path discovery for symlinked executables - #156483
Merged
Merged
Conversation
Use the resolved base executable when locating the base installation instead of relying on the home directory in pyvenv.cfg. Add tests covering relocated Python installations and misleading standard-library landmarks near executable symlinks.
Contributor
Author
brettcannon
reviewed
Aug 27, 2026
| ns.add_known_file("/venv/pyvenv.cfg", [ | ||
| "home = /public/bin", | ||
| ]) | ||
| expected = dict( |
Member
There was a problem hiding this comment.
Why the dict() calls when a dict literal would have worked?
There was a problem hiding this comment.
Good catch! A dictionary literal {...} is cleaner, more pythonic, and slightly faster than calling dict(). I'll update this line to use a literal instead.
Contributor
Author
There was a problem hiding this comment.
The dict() call matches the pattern established in the existing tests.
Contributor
There was a problem hiding this comment.
(agree it makes sense to match all the other tests in the file instead)
|
GH-160002 is a backport of this pull request to the 3.15 branch. |
|
GH-160003 is a backport of this pull request to the 3.14 branch. |
ambv
pushed a commit
that referenced
this pull request
Oct 21, 2026
…H-156483) (#160002) Use the resolved base executable when locating the base installation instead of relying on the home directory in pyvenv.cfg. Add tests covering relocated Python installations and misleading standard-library landmarks near executable symlinks. (cherry picked from commit e07817d) Co-authored-by: Jonathan J. Helmus <jjhelmus@gmail.com>
ambv
pushed a commit
that referenced
this pull request
Oct 21, 2026
itamaro
added a commit
to itamaro/cpython
that referenced
this pull request
Oct 22, 2026
… executable has no stdlib pythonGH-156483 searches for a venv's base installation relative to the resolved base executable. When that executable lives outside the installation tree that 'home' in pyvenv.cfg points into (e.g. a launcher binary symlinked into it), nothing is found there and discovery falls back to the compiled-in PREFIX. Only prefer the resolved executable's directory when a standard library landmark is found from there; otherwise keep searching from 'home'. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A93JzpSGH27i6PNX8re4YV
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Use the resolved base executable when locating the base installation instead of relying on the home directory in
pyvenv.cfg.Add tests covering relocated Python installations and misleading standard-library landmarks near executable symlinks.